package com.Hwadee.eduservice.controller.admin;

import com.Hwadee.commonutils.R;
import com.Hwadee.eduservice.service.EduCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/eduservice/comment")
public class EduCommentController {
    @Autowired
    private EduCommentService commentService;

    //分页查询课程评论
    @GetMapping("/getCourseComment/{current}/{limit}")
    public R getCourseComment(@PathVariable("current") long current,
                              @PathVariable("limit") long limit) {
        Map<String, Object> courseComment = commentService.getAdminCourseComment(current, limit);
        return R.ok().data(courseComment);
    }

    //删除评论
    @DeleteMapping("/deleteComment/{id}")
    public R deleteComment(@PathVariable("id") String id) {
        boolean remove = commentService.removeById(id);
        if (remove) {
            return R.ok().message("删除评论成功！");
        }
        else {
            return R.error().message("删除评论失败！");
        }
    }

}
